﻿using AutoMapper;
using Microsoft.Extensions.DependencyInjection;

namespace Mes.Application.AutoMapper
{
    public static class AutoMapperExtension
    {
        public static IServiceCollection EasyAddAutoMapper(this IServiceCollection services)
        {
            var scanassemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.IsDynamic&&x.FullName.Contains("Mes.Application", StringComparison.OrdinalIgnoreCase)).ToList();
            return services.AddAutoMapper(cfg =>
            {
                cfg.ShouldMapField = fi => false;
            }, scanassemblies, ServiceLifetime.Singleton);
        }
    }
}
